package common;

/**
 * 
 * @author Boshi Li 
 * @version 1.1
 * Thanks for Ashton
 */

public class Token 
{
	private final TokenType type;
	private final Integer value;
	
	public Token(TokenType type, Integer value){
		this.type = type;
		this.value = value;
	}
	
	public int getValue(){
		return value == null ? -1 : value ;
	}
	
	public TokenType getType()
	{
		return type;
	}
	
	@Override
	public boolean equals( Object object ){
        if(this == object)
            return true;
	    if(! (object instanceof Token))
	            return false;

	    Token token = (Token) object;
	    return token.type == this.type && token.value == this.value;
	}
	
	@Override
	public String toString(){
		 if(value == null||value==-1)
             return String.format("(%s,null)", type);
		 return String.format("(%s, %d)", type, value);
	}

}
